// ==========================================================================
// GFast自动生成dao internal操作代码。
// 生成日期：2023-12-01 16:05:36
// 生成路径: internal/app/plugins/sms/dao/internal/plugin_sms_log.go
// 生成人：gfast
// desc:短信日志
// company:云南奇讯科技有限公司
// ==========================================================================

package internal

import (
	"context"

	"github.com/gogf/gf/v2/database/gdb"
	"github.com/gogf/gf/v2/frame/g"
)

// PluginSmsLogDao is the manager for logic model data accessing and custom defined data operations functions management.
type PluginSmsLogDao struct {
	table   string              // Table is the underlying table name of the DAO.
	group   string              // Group is the database configuration group name of current DAO.
	columns PluginSmsLogColumns // Columns is the short type for Columns, which contains all the column names of Table for convenient usage.
}

// PluginSmsLogColumns defines and stores column names for table plugin_sms_log.
type PluginSmsLogColumns struct {
	Id         string // ID
	SmsType    string // 短信平台的类型
	MsgType    string // 短信的类型
	Templateid string // 模板id
	Mobiles    string // 电话号码
	Params     string // 模板参数
	Result     string // 发送结果
	CreatedAt  string // 发送日期
	UpdatedAt  string //
	DeletedAt  string //
}

var pluginSmsLogColumns = PluginSmsLogColumns{
	Id:         "id",
	SmsType:    "sms_type",
	MsgType:    "msg_type",
	Templateid: "templateid",
	Mobiles:    "mobiles",
	Params:     "params",
	Result:     "result",
	CreatedAt:  "created_at",
	UpdatedAt:  "updated_at",
	DeletedAt:  "deleted_at",
}

// NewPluginSmsLogDao creates and returns a new DAO object for table data access.
func NewPluginSmsLogDao() *PluginSmsLogDao {
	return &PluginSmsLogDao{
		group:   "default",
		table:   "plugin_sms_log",
		columns: pluginSmsLogColumns,
	}
}

// DB retrieves and returns the underlying raw database management object of current DAO.
func (dao *PluginSmsLogDao) DB() gdb.DB {
	return g.DB(dao.group)
}

// Table returns the table name of current dao.
func (dao *PluginSmsLogDao) Table() string {
	return dao.table
}

// Columns returns all column names of current dao.
func (dao *PluginSmsLogDao) Columns() PluginSmsLogColumns {
	return dao.columns
}

// Group returns the configuration group name of database of current dao.
func (dao *PluginSmsLogDao) Group() string {
	return dao.group
}

// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
func (dao *PluginSmsLogDao) Ctx(ctx context.Context) *gdb.Model {
	return dao.DB().Model(dao.table).Safe().Ctx(ctx)
}

// Transaction wraps the transaction logic using function f.
// It rollbacks the transaction and returns the error from function f if it returns non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note that, you should not Commit or Rollback the transaction in function f
// as it is automatically handled by this function.
func (dao *PluginSmsLogDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
	return dao.Ctx(ctx).Transaction(ctx, f)
}
